package net.dreamlu.test;

import java.net.URL;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import com.googlecode.htmlcompressor.compressor.HtmlCompressor;
import com.googlecode.htmlcompressor.compressor.YuiCssCompressor;
import com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor;

public class TTTTTT {
    
    public static void main(String[] args) throws Exception {
        HtmlCompressor compressor = new HtmlCompressor();

        compressor.setEnabled(true);                   //if false all compression is off (default is true)
        compressor.setRemoveComments(true);            //if false keeps HTML comments (default is true)
        compressor.setRemoveMultiSpaces(true);         //if false keeps multiple whitespace characters (default is true)
        compressor.setRemoveIntertagSpaces(true);      //removes iter-tag whitespace characters
        //compressor.setRemoveQuotes(true);              //removes unnecessary tag attribute quotes
        compressor.setSimpleDoctype(true);             //simplify existing doctype
//        compressor.setRemoveScriptAttributes(true);    //remove optional attributes from script tags
//        compressor.setRemoveStyleAttributes(true);     //remove optional attributes from style tags
//        compressor.setRemoveLinkAttributes(true);      //remove optional attributes from link tags
//        compressor.setRemoveFormAttributes(true);      //remove optional attributes from form tags
//        compressor.setRemoveInputAttributes(true);     //remove optional attributes from input tags
//        compressor.setSimpleBooleanAttributes(true);   //remove values from boolean tag attributes
        //compressor.setRemoveJavaScriptProtocol(true);  //remove "javascript:" from inline event handlers
        //compressor.setRemoveHttpProtocol(true);        //replace "http://" with "//" inside tag attributes
        //compressor.setRemoveHttpsProtocol(true);       //replace "https://" with "//" inside tag attributes
        compressor.setPreserveLineBreaks(false);        //preserves original line breaks
        //compressor.setRemoveSurroundingSpaces("br,p"); //remove spaces around provided tags

        compressor.setCompressCss(true);               //compress inline css 
        compressor.setCompressJavaScript(true);        //compress inline javascript
        compressor.setYuiCssLineBreak(80);             //--line-break param for Yahoo YUI Compressor 
        compressor.setYuiJsDisableOptimizations(true); //--disable-optimizations param for Yahoo YUI Compressor 
        compressor.setYuiJsLineBreak(-1);              //--line-break param for Yahoo YUI Compressor 
        compressor.setYuiJsNoMunge(true);              //--nomunge param for Yahoo YUI Compressor 
        compressor.setYuiJsPreserveAllSemiColons(true);//--preserve-semi param for Yahoo YUI Compressor 

        //use Google Closure Compiler for javascript compression
        compressor.setJavaScriptCompressor(new YuiJavaScriptCompressor());

        //use your own implementation of css comressor
        compressor.setCssCompressor(new YuiCssCompressor());
        Document html = Jsoup.parse(new URL("http://www.dreamlu.net/"), 3000);
        
        String compressedHtml = compressor.compress(html.toString());
        System.out.println(compressedHtml);
    }
}
